﻿@page "/SysPatientLog/Edit/{id}"
@using SelfService.ViewModel.SysPatientLogVMs;
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
    <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">

            <Select @bind-Value="@Model.Entity.PatientId" Items="@AllSysPatients" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]"/>
            <BootstrapInput @bind-Value="@Model.Entity.IdCardNo"  />
            <BootstrapInput @bind-Value="@Model.Entity.Action"  />
            <BootstrapInputNumber @bind-Value="@Model.Entity.Amount"  />
            <DateTimePicker @bind-Value="@Model.Entity.CreateTime"  />
    </Row>
    <div class="modal-footer table-modal-footer">
        <Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />
        <Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Edit"]" IsAsync="true" />
    </div>
</ValidateForm>

@code {

    private SysPatientLogVM Model = null;
    private ValidateForm vform { get; set; }
    [Parameter]
    public string id { get; set; }

    private List<SelectedItem> AllSysPatients = new List<SelectedItem>();


    protected override async Task OnInitializedAsync()
    {

        AllSysPatients = await WtmBlazor.Api.CallItemsApi("/api/SysPatientLog/GetSysPatients", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);

        var rv = await WtmBlazor.Api.CallAPI<SysPatientLogVM>($"/api/SysPatientLog/{id}");
        Model = rv.Data;
         await base.OnInitializedAsync();
   }

    private async Task Submit(EditContext context)
    {
        await PostsForm(vform, $"/api/SysPatientLog/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
    }

    public void OnClose()
    {
        CloseDialog();
    }

}
